package de.dhbw.asa.controller;


import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

import de.dhbw.asa.model.Customer;


@ManagedBean
@RequestScoped
public class LoginCtrl
{

	@ManagedProperty(value = "#{customer}")
	Customer customer;
	
	boolean bLoggedIn = false;
	
    public String checkPW()
    {
    	System.out.println("Checking password:");
    	System.out.println("CustomerNr: "+customer.getiCustomerNr());
    	System.out.println("Entered Password: "+customer.getsEnteredPassword());
    	customer.load(customer.getiCustomerNr());
    	System.out.println("Password of loaded Customer: "+customer.getsPassword());
        if(customer.getsPassword().equals(customer.getsEnteredPassword()))
        {
        	bLoggedIn = true;
        	return "products";
        }
        else
        {
        	bLoggedIn = false;
        	return "failure";
        }
        
    }

	public Customer getCustomer() 
	{
		return customer;
	}

	public void setCustomer(Customer customer) 
	{
		this.customer = customer;
	}

}
